home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Unicode Reordering.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-18  |  2.5 KB  |  93 lines  |  [TEXT/KAHL]

  1. /****************************************************************************************************
  2.     6/96 bob    Updated #includes to support changed GX Library names.
  3.     
  4.     ©1990 - 1996  Apple Computer, Inc.
  5.     All rights reserved.
  6. ****************************************************************************************************/
  7. #include <Types.h>
  8. #include <QuickDraw.h>
  9. #include <Fonts.h>
  10. #include <Windows.h>
  11. #include <Menus.h>
  12. #include <SegLoad.h>
  13. #include <Memory.h>
  14. #include <Desk.h>
  15.  
  16. #include <GXGraphics.h>
  17. #include "GraphicsLibraries.h"
  18. #include <GXEnvironment.h>
  19.  
  20. #include <GXTypes.h>
  21. #include <GXLayout.h>
  22. #include "LayoutLibrary.h"
  23.  
  24. #include "SampleInterface.h"
  25.  
  26. short MyStrLen(char *x);
  27. static short MyStrLen(x)
  28. char    *x;
  29.     {
  30.     short c = 0;
  31.     while (*x++) c++;
  32.     return c;
  33.     }    /* MyStrLen */
  34.  
  35. void UnicodeReordering(WindowPtr sampleWindow)
  36.     {
  37.     /* Variables */
  38.     char            *myString = "ABCDEFGHIJ";
  39.     gxLayoutOptions    gxLayoutOptions;
  40.     gxPoint            myPoint;
  41.     gxRunControls        gxRunControls;
  42.     gxShape            layout;
  43.     short            i, len, level = 0, runLengths[5], runLevels[5];
  44.     gxStyle            reversedStyle, romanStyle, styleArray[5];
  45.     gxViewPort        aViewPort;
  46.     
  47.     /* Initialization */
  48.     
  49.     myPoint.x = ff(30);
  50.     myPoint.y = ff(50);
  51.     
  52.     aViewPort = GXNewWindowViewPort(sampleWindow);
  53.     SetDefaultViewPort(aViewPort);
  54.     
  55.     len = MyStrLen(myString);
  56.     for (i = 0; i < 5; i++) runLengths[i] = 2;
  57.     
  58.     romanStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(50), 0, nil, nil, 0, nil);
  59.     
  60.     InitializeRunControls(&gxRunControls);
  61.     gxRunControls.flags = gxImposeRightToLeft;
  62.     reversedStyle = NewLayoutStyle(
  63.         (char *) "\pZapf Chancery Medium Italic", ff(50), 0, &gxRunControls, nil, 0, nil);
  64.     
  65.     styleArray[0] = styleArray[2] = styleArray[4] = romanStyle;
  66.     styleArray[1] = styleArray[3] = reversedStyle;
  67.     
  68.     layout = GXNewLayout(
  69.         1, &len, (void *) &myString,
  70.         5, runLengths, styleArray,
  71.         1, &len, &level,
  72.         nil, &myPoint);
  73.     GXDrawShape(layout);
  74.     
  75.     InitializeLayoutOptions(&gxLayoutOptions);
  76.     gxLayoutOptions.flags = gxImposeLeftToRight;
  77.     level = 1;
  78.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 1, &len,  &level,&gxLayoutOptions, nil);
  79.     GXMoveShape(layout, 0, ff(75));
  80.     GXDrawShape(layout);
  81.     
  82.     runLevels[0] = runLevels[4] = 0;
  83.     runLevels[1] = runLevels[2] = runLevels[3] = 1;
  84.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 5, runLengths, runLevels, nil, nil);
  85.     GXMoveShape(layout, 0, ff(75));
  86.     GXDrawShape(layout);
  87.     
  88.     GXDisposeShape(layout);
  89.     GXDisposeStyle(romanStyle);
  90.     GXDisposeStyle(reversedStyle);
  91.     GXDisposeViewPort(aViewPort);
  92.     }    /* main */
  93.